package goleetcode

import "duan.com/leetcode/utils"

func postorder(root *utils.Node) []int {
	if root == nil {
		return nil
	}
	ans := []int{}
	var dfs func(*utils.Node)
	dfs = func(node *utils.Node) {
		if node == nil {
			return 
		}
		for _, ch := range node.Children {
			dfs(ch)
		}
		ans = append(ans, node.Val)
	}
	dfs(root)
	return ans
}